dojo.provide("dojoc.form.Timestamp");

dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dijit._Calendar");
dojo.require("dojoc.form.TimeSpinner");

dojo.declare("dojoc.form.Timestamp",
	[dijit._Widget, dijit._Templated],
{
	templatePath: dojo.moduleUrl("dojoc.form", "templates/Timestamp.html"),

	widgetsInTemplate: true,

	postCreate: function() {
		this.connect(this.calendar, "onValueSelected", "_onValueSelected");
		this.inherited(arguments);
	},
	
	setValue: function(/*Date*/ value){
		dojo.deprecated("dojoc.form.Timestamp:setValue() is deprecated.  Use attr('value', ...) instead.", "", "2.0");
		this.attr('value', value);
	},
	
	_setValueAttr: function(/*Date*/ value){
		console.debug(value);
		this.calendar.attr('value',value);
		this.timeSpinner.attr('value',value);
	},
	
	getValue: function(/*Date*/ value){
		dojo.deprecated("dojoc.form.Timestamp:getValue() is deprecated.  Use attr('value', ...) instead.", "", "2.0");
		this.attr(value);
	},

	_getValueAttr: function() {
		var value = this.calendar.value;
		var time = this.timeSpinner.attr('value');
		value.setHours(time.getHours());
		value.setMinutes(time.getMinutes());
		value.setSeconds(time.getSeconds());
		return value;
	},

	_onValueSelected: function() {
		this.onValueSelected(this.attr('value'));
	},

	onValueSelected: function(value) {}
});
	
